package cn.bouncyslime.graduationProject.nba.controller;

import cn.bouncyslime.graduationProject.nba.service.CompetitionService;
import cn.bouncyslime.graduationProject.nba.service.PlayerDataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;
import java.util.Map;

/**
 * @author 张一卓
 * @date 2020/4/5 16:20
 **/
@Controller
public class IndexController {

    private static final Logger logger = LoggerFactory.getLogger(IndexController.class);

    @Autowired
    CompetitionService competitionService;
    @Autowired
    PlayerDataService playerDataService;

    @RequestMapping(value = "/", method = {RequestMethod.POST, RequestMethod.GET})
    public String index(ModelMap modelMap){
        List<Map<String, Object>> eastList = competitionService.listEastTeamGradeCurrentSeason();
        List<Map<String, Object>> westList =competitionService.listWestTeamGradeCurrentSeason();
        modelMap.addAttribute("eastWinRateList", eastList);
        modelMap.addAttribute("westWinRateList", westList);
        List<Map<String, Object>> playerRSTopTenAvgScore = playerDataService.listRSTopTenAvgScore();
        List<Map<String, Object>> playerRSTopTenAvgAssists =playerDataService.listRSTopTenAvgAssists();
        List<Map<String, Object>> playerRSTopTenAvgBlockShot =playerDataService.listRSTopTenAvgBlockShot();
        List<Map<String, Object>> playerRSTopTenAvgFault =playerDataService.listRSTopTenAvgFault();
        List<Map<String, Object>> playerRSTopTenAvgFoul =playerDataService.listRSTopTenAvgFoul();

        List<Map<String, Object>> playerRSTopTenAvgRebound =playerDataService.listRSTopTenAvgRebound();
        List<Map<String, Object>> playerRSTopTenAvgSteal =playerDataService.listRSTopTenAvgSteal();
        List<Map<String, Object>> playerRSTopTenEfficiencyRating =playerDataService.listRSTopTenEfficiencyRating();
        List<Map<String, Object>> playerRSTopTenTrueShootingPercentage =playerDataService.listRSTopTenTrueShootingPercentage();
        modelMap.addAttribute("playerRSTopTenAvgScore", playerRSTopTenAvgScore);
        modelMap.addAttribute("playerRSTopTenAvgAssists", playerRSTopTenAvgAssists);
        modelMap.addAttribute("playerRSTopTenAvgBlockShot", playerRSTopTenAvgBlockShot);
        modelMap.addAttribute("playerRSTopTenAvgFault", playerRSTopTenAvgFault);
        modelMap.addAttribute("playerRSTopTenAvgFoul", playerRSTopTenAvgFoul);
        modelMap.addAttribute("playerRSTopTenAvgRebound", playerRSTopTenAvgRebound);
        modelMap.addAttribute("playerRSTopTenAvgSteal", playerRSTopTenAvgSteal);
        modelMap.addAttribute("playerRSTopTenEfficiencyRating", playerRSTopTenEfficiencyRating);
        modelMap.addAttribute("playerRSTopTenTrueShootingPercentage", playerRSTopTenTrueShootingPercentage);
        logger.warn("========= warn ==========");
        logger.warn("========= warn ==========");
        logger.info("info");
        logger.debug("debug");
        return "index";
    }


    @RequestMapping(value = "/index", method = {RequestMethod.POST, RequestMethod.GET})
    public String index(){
        return "index";
    }
}